package com.gitee.zhangchenyan.takin.common.result;

public class ResultUtils {

    public static Result success() {
        Result result = new Result();
        result.setCode(ResultCode.SUCCESS);
        result.setMessage("请求成功!");
        return result;
    }

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode(ResultCode.SUCCESS);
        result.setData(data);
        result.setMessage("请求成功!");
        return result;
    }

    public static Result notLogin() {
        Result result = new Result();
        result.setCode(ResultCode.NOT_LOGIN);
        result.setMessage("未登录或者登录过期");
        return result;
    }

    public static Result notAuthority(String msg) {
        Result result = new Result();
        result.setCode(ResultCode.NOT_AUTHORITY);
        result.setMessage(msg);
        return result;
    }

    public static Result unknown(String message) {
        Result result = new Result();
        result.setCode(ResultCode.UNKNOWN);
        result.setMessage(message);
        return result;
    }

}
